#ifndef _CONVERT_H_
#define _CONVERT_H_

#include "bencode.h"
#include "alp_iconv.h"
#include "alp_type.h"
#include "alp.h"

/**
 *	convert to utf-8 form
 *	@param	node  the bencode node
 *	@param	fromcode	the current form that the node is in
 *	@return 0 for OK
 *			-1 on error
 */
alp_status_t convert_node(bencode_node_t * node, const char* fromcode);

/**
 *	convert a string to utf-8 formed string
 *	@param	node  the bencode node containing the source string
 *	@param	fromcode	the current form that the string is in
 *	@return 0 for OK
 *			-1 on error
 */
alp_status_t convert_string(bencode_node_t* node, const char* fromcode); 

/**
 *	convert a list to utf-8 formed string
 *	@param	node  the bencode node containing the source list
 *	@param	fromcode	the current form that the list is in
 *	@return 0 for OK
 *			-1 on error
 */
alp_status_t convert_list(alp_list_t* list, const char* fromcode);

/**
 *	convert a dictionary to utf-8 formed string
 *	@param	node  the bencode node containing the source dictionary
 *	@param	fromcode	the current form that the dictionary is in
 *	@return 0 for OK
 *			-1 on error
 */
alp_status_t convert_dict(alp_dict_t* dict, const char* fromcode);

/**
 *	convert to utf-8 formed string
 *	@param	node  the bencode node containing the resources
 *	@return 0 for OK
 */
alp_status_t convert(bencode_node_t* node);

/**
 *	check if current fromcode type is utf-8
 *	@param	c the fromcode type will be checked
 *	@return	0 on isn't utf-8
 *			1 on is utf-8
 */
alp_status_t isUTF8(const char* c);

#endif //_CONVERT_H_